import React, { Component } from 'react'
import Item from '../Item/Item'
import context from '../../context'
import './List.css'
export default class List extends Component {
  // List需要接收context传过来的数据,所以给List添加静态属性contextType
  static contextType = context
  render() {
    return (
      <ul className="todo-main">
        {/* this.context就是app中todoList的数据 */}
        {this.context.map((item) => (
          <Item key={item.id} todo={item}></Item>
        ))}
      </ul>
    )
  }
}
